﻿// Xshell Unit Tests - XmlConfigReader
// 
// <copyright file="XmlConfigReaderUnitTests.cs" company="TaskyMedia LLC">
//   Copyright © 2010 TaskyMedia LLC
// </copyright>
namespace XshellUnitTests
{
    using System;
    using System.IO;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// <see cref="Xshell.XmlConfigReader"/> unit tests.
    /// </summary>
    [TestClass]
    public class XmlConfigReaderUnitTests
    {
        /// <summary>
        /// <see cref="Xshell.XmlConfigReader"/> file path constructor test.
        /// </summary>
        [TestMethod]
        public void XmlConfigReaderConstructorPathTest()
        {
            // Create the dummy XML file
            string tempXml = "<?xml version=\"1.0\"?>";
            string tempFile = Path.GetTempFileName();
            File.WriteAllText(tempFile, tempXml);

            Xshell.XmlConfigReader xmlConfigReader = new Xshell.XmlConfigReader(tempFile);
            Assert.IsNotNull(xmlConfigReader);

            File.Delete(tempFile);
        }

        /// <summary>
        /// <see cref="Xshell.XmlConfigReader"/> stream constructor test.
        /// </summary>
        [TestMethod]
        public void XmlConfigReaderConstructorStreamTest()
        {
            // Create the dummy XML file
            string tempXml = "<?xml version=\"1.0\"?>";
            string tempFile = Path.GetTempFileName();
            File.WriteAllText(tempFile, tempXml);

            using (FileStream fs = File.OpenRead(tempFile))
            {
                Xshell.XmlConfigReader xmlConfigReader = new Xshell.XmlConfigReader(fs);
                Assert.IsNotNull(xmlConfigReader);
            }

            File.Delete(tempFile);
        }
    }
}
